﻿using ParkSaleForAdmin.Data;
using ParkSaleForAdmin.Foundation;
using System.Windows;

namespace ParkSaleForAdmin.FunctionWindow
{
    class ADInfo
    {
        [DataToUI("广告号", "id", false)]
        public string ID
        {
            get;
            set;
        }
        [DataToUI("图片地址", "image")]
        public string ImagePath
        {
            get;
            set;
        }
        [DataToUI("广告标题", "title")]
        public string Title
        {
            get;
            set;
        }
        [DataToUI("广告链接")]
        public string url
        {
            get;
            set;
        }
        [DataToUI("广告归属者")]
        public string belong
        {
            get;
            set;
        }
    }
    class AD : BasicManagerWindow<ADInfo>
    {
        public override string TableName => "Advertisement";

        protected override bool NullablePending(string n)
        {

            if (n.Equals("image") || n.Equals("url"))
            {
                nullobj++;
                return true;

            }
            return false;
        }

        int nullobj = 0;
        protected override void add_Click(object sender, RoutedEventArgs e)
        {
            nullobj = 0;
            base.add_Click(sender, e);
        }
        protected override int StandAppendArgsCount => base.StandAppendArgsCount - nullobj * 2;


        public override string DeleteStr(ADInfo obj)
        {
            return SQLHelpler.MakeSelectStr(TableName, "id", obj.ID);
        }

        public override string AppendStr(ADInfo obj)
        {
            return $"select * from {TableName} where id=99999";
        }

        public override string ChangeStr(ADInfo obj)
        {
            return SQLHelpler.MakeSelectStr(TableName, "id", obj.ID);
        }

    }
}
